<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    .error{
      color:red;
      font-size: 12px;

    }

  </style>
</head>
<body>


<form action="">
  <div>
    <label for="input-name">用户名</label>
    <input type="text" id="input-name" name="name">
    <span class="error"></span>
  </div>
  <div>
    <label for="input-password">密码</label>
    <input type="password" id="input-password" name="password">
    <span class="error"></span>
  </div>
  <div>
    <input type="button" id="btn" value="提交">
  </div>
</form>



</body>
<script src="jquery.js"></script>
<script>

  $('#btn').click(function () {
    var uname = $('#input-name').val();
    var pwd = $('#input-password').val();
    if (uname.trim().length === 0){
      $('#input-name').next().text('用户名不能为空');
    }else {
      $('#input-name').next().text('√');
    };

    if (pwd.trim().length === 0){
      $('#input-password').next().text('密码不能为空');
    }else {
      $('#input-password').next().text('√');
    };

  })



</script>



</html>